﻿<?php

if(!defined('IN_PHPSCUP'))exit('hacking'); 
class ProtApp extends BaseApp
{

    var $type = 'prot';
	
    function index()
    {
		if(!isset($_POST['word']))
		{
		$_POST['word'] = '';
		}
		if(!isset($_POST['cat']))
		{
		$_POST['cat'] = '';
		}		
		if(!isset($_GET['cat']))
		{
		$_GET['cat'] = '';
		}
		if(!isset($_GET['v']))
		{
		$_GET['v'] = '';
		}	
		$cat = intval($_GET['cat']);
		if(empty($cat))
		{
		$cat = intval($_POST['cat']);
		}
		
		
	    $word = $_POST['word'];
		$word_array = explode(' ',$word);
		
		foreach($word_array as $key => $value)
		{
			if(!$value)
			{
             unset($word_array[$key]);
		    }  
		}
        $order = '';
		$v = $_GET['v'];
		//var_dump($v);
		
		if($v == 'timeasc')
		{
        $order = 'A.add_time asc';
		}
		else if($v == 'timedesc')
		{
        $order = 'A.add_time desc';		
		}
		else if($v == 'showyes')
		{
        $order = 'A.is_show desc';		
		}
		else if($v == 'showno')
		{
        $order = 'A.is_show asc';		
		}
		else if($v == 'topyes')
		{
        $order = 'A.is_top desc';		
		}
		else if($v == 'topno')
		{
        $order = 'A.is_top asc';		
		}
		else if($v == 'recyes')
		{
        $order = 'A.is_recommend desc';		
		}
		else if($v == 'recno')
		{
        $order = 'A.is_recommend asc';		
		}
		else if($v == 'indexyes')
		{
        $order = 'A.is_index desc';		
		}
		else if($v == 'indexno')
		{
        $order = 'A.is_index asc';		
		}
			$GLOBALS['Lang']->_get_lang('prot');		
					 
		require(ROOT_PATH . '/lib/nav.lib.php');
		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
	    $order = '';
	
		$TB_new = &$this->_model('prot');
				
		$data = $TB_new->show($order,$v,$word_array,$cat);
		
		
		
		//liaoamin add
		$tmp_pages=array();
		$this->_build_pages($data['page']['totalpage'],$data['page']['head'],$tmp_pages);
        $this->assign('lw_data', $data['data']);		
		$this->assign('lw_page', $data['page']);	
		$this->assign('lw_pages',$tmp_pages);
		
		
        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);			
		
	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
		
	 	$parent_id=get_parent_id($_GET['cat']);
		

		$this->assign('parent_id',$parent_id);
        $this->assign('categorydata', $categorydata);							
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE);
        $this->assign('page_description', SITE_DESCRIPTION);
        $this->assign('page_keywords', SITE_KEYWORDS);	
		$this->assign('bg_pic_url',$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');		
        $this->assign('site_url',SITE_URL);
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);
				$this->assign('bg_pic_url',$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
		
        $this->display('prot.view.html');
    }

    function show()
    {

	    $id = $_GET['id'];
		require(ROOT_PATH . '/lib/nav.lib.php');
			$GLOBALS['Lang']->_get_lang('prot');		
		$nav = new Nav($GLOBALS['SCup']->SCup_nav_file);
		
        $this->assign('navigation', $nav->_get_nav());	
        $pic_data = include(ROOT_PATH . '/data/cache/rollpic_'.trim($GLOBALS['Lang']->_lang_tp).'.php'); 
		$this->assign('pic_data', $pic_data);	
	
		$TB_new = &$this->_model('prot');
				
		$data = $TB_new->oneshow($id);	
				$TB_new->vistnumadd($id);	
        $this->assign('data', $data);			
        $qq_data = array();
        $qq_temp1 = del_empty_var(explode('|', QQ_SET_DATA));
		foreach($qq_temp1 as $key=>$value)
		{
           $qq_temp2 = del_empty_var(explode(':', $value));	
		   $qq_data[$qq_temp2[0]] = $qq_temp2[1];     
		}
        $this->assign('qq_data',$qq_data);	

		$TB_pic = &$this->_model('upfile');
		$upfile_data = $TB_pic->selct($id);
        $this->assign('upfiledata', $upfile_data);		

	 	$categorydata = & $GLOBALS['SCup']->_get_category_data($this->type);
        $this->assign('langdata', $GLOBALS['Lang']->_get_lang_typesdata());	 		
        $this->assign('categorydata', $categorydata);							
        $this->assign('login_icon', $GLOBALS['SCup']->SCup_user_checking);	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', SITE_TITLE.'-'.$data['title']);
        $this->assign('page_description', SITE_DESCRIPTION.'-'.$data['description']);
        $this->assign('page_keywords', SITE_KEYWORDS.'-'.$data['keywords']);	
		$this->assign('bg_pic_url',SITE_URL.'/'.$GLOBALS['SCup']->SCup_name.'/view/'.VIEW_TYPE .'/style/'.CSS_TYPE.'/');		
        $this->assign('site_url',SITE_URL);
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');		
        $this->assign('langtype', trim($GLOBALS['Lang']->_lang_tp));
		
        $this->display('protshow.view.html');
    }




  
}

?>